﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;

namespace GSite.Utils.Unity
{
    /// <summary>
    /// Клас съдържащ статични помощни методи за Unity Framework
    /// </summary>
    public class UnityHelpers
    {
        private static volatile IUnityContainer _defaultContainer = null;
        private static object _syncRoot = new object();

        /// <summary>
        /// Извлича контейнера по подразбиране за Unity Framework
        /// </summary>
        /// <returns></returns>
        public static IUnityContainer GetDefaultContainer()
        {
            if (_defaultContainer == null)
            {
                lock (_syncRoot)
                {
                    if (_defaultContainer == null)
                    {
                        _defaultContainer = new UnityContainer().LoadConfiguration();
                    }
                }
            }

            return _defaultContainer;
        }
    }
}
